package com.zbkj.crmeb.enums;

import java.math.BigDecimal;

/**
 * 头程物流价格枚举
 */

public enum FirstLogisticsIntervalEnum {
    INTERVAL_1(BigDecimal.ZERO, new BigDecimal(1000),new BigDecimal(50)),
    INTERVAL_2(new BigDecimal(1001), new BigDecimal(2000),new BigDecimal("0.05")),
    INTERVAL_3(new BigDecimal(2001), new BigDecimal(2222),new BigDecimal(100)),
    INTERVAL_4(new BigDecimal(2223), new BigDecimal(4000),new BigDecimal("0.045")),
    INTERVAL_5(new BigDecimal(4001), new BigDecimal(4500),new BigDecimal(180)),
    INTERVAL_6(new BigDecimal(4501), new BigDecimal(6000),new BigDecimal("0.04")),
    INTERVAL_7(new BigDecimal(6001), new BigDecimal(6857),new BigDecimal(240)),
    INTERVAL_8(new BigDecimal(6858), new BigDecimal(10000),new BigDecimal("0.035")),
    INTERVAL_9(new BigDecimal(10001), new BigDecimal(11667),new BigDecimal(350)),
    INTERVAL_10(new BigDecimal(11668), new BigDecimal(20000),new BigDecimal("0.03")),
    INTERVAL_11(new BigDecimal(20001), new BigDecimal(30000),new BigDecimal(600)),
    INTERVAL_12(new BigDecimal(30001), BigDecimal.valueOf(Double.MAX_VALUE),new BigDecimal(600)),
    ;

    //最低价格
    private final BigDecimal minPrice;
    //最高价格
    private final BigDecimal maxPrice;
    //加价价格
    private final BigDecimal premiumPrice;

    FirstLogisticsIntervalEnum(BigDecimal minPrice, BigDecimal maxPrice, BigDecimal premiumPrice) {
        this.minPrice = minPrice;
        this.maxPrice = maxPrice;
        this.premiumPrice = premiumPrice;
    }

    public static BigDecimal valueOfPremiumPrice(BigDecimal price) {
        for (FirstLogisticsIntervalEnum value : values()) {
            if (price.compareTo(value.getMinPrice()) > -1 && price.compareTo(value.getMaxPrice()) < 1) {
                return value.getPremiumPrice();
            }
        }
        return BigDecimal.ZERO;
    }

    public BigDecimal getMinPrice() {
        return minPrice;
    }

    public BigDecimal getMaxPrice() {
        return maxPrice;
    }

    public BigDecimal getPremiumPrice() {
        return premiumPrice;
    }

}
